<script type="text/javascript">

function LoadTP(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp == null)
{
alert ("Browser does not support HTTP Request");
return;
}

var url = "modules/customers/load_thanhpho.php";
url = url + "?sltinhthanh=" + str;

xmlhttp.onreadystatechange = stateChanged1;
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
}

function stateChanged1()
{
if (xmlhttp.readyState == 4)
{
document.getElementById("tinhthanh").innerHTML = xmlhttp.responseText;

}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}

</script>   
<table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="text-top">.:. Danh sách đơn hàng</td>
        </tr>
      </tbody></table>
      <table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light"> 
          <td class="t-l"></td>
          <td class="t-c"></td>
          <td class="t-r"></td>
        </tr>
        <tr class="light">
          <td class="c-l"></td>
          <td class="c-c" valign="top">
  <form action="" method="post">

     <p>
    &nbsp;&nbsp;
    <span>Tên hợp đồng</span> 
    <span> 
    	<input type="text" style="width:150px;" name="TenKh"/>
    </span> 
    &nbsp;
    <span>Người quản lý </span>
    <span> 
    	<select name="nguoiql"> 
        	
        	<option value="">--Lựa chọn--</option>
           <?php 
		   		$sql_nql=mysql_query("select account_id,account_name from tb_account_admin");
				while($row_nql=mysql_fetch_array($sql_nql))
				{	
		   ?>
           	<option value="<?php echo $row_nql['account_id'];?>"><?php echo $row_nql['account_name'];?> </option>
           <?php }?>
        </select>
    </span>
    &nbsp;Trạng thái<span> 
    	<select id="tthd_txt"  name="trangthai">
            <option value="">Lựa chọn </option>
            <option value="1">Đang thực hiện</option>
            <option value="2">Kết thúc</option>
            <option value="3">Đang hoãn</option>
            <option value="4">Hủy</option>
        </select>
    </span>
    
    <span><input name="button" type="submit" value="Tìm kiếm" class="cs-title-timkiem"/></span>
    &nbsp;&nbsp;</p>
    
 </form>
    <div class="clear" style="height:10px"></div>
<?php 
	$search=$_POST['TenKh'];
	$loaiKh=$_POST['loaiKh'];
	$DonViQl=$_POST['DonViQl'];
	$sltinhthanh = $_POST['sltinhthanh'];
	$idquanhuyen = $_POST['idquanhuyen'];
?>

<?php 
	$user=$_SESSION['userid'];
	$sqlstring="select  
						donhang.id,
						donhang.code,
						donhang.name,
						donhang.kh_id,
						donhang.giatri,
						donhang.ngayban,
						donhang.manager,
						donhang.creater
						
					from 
						donhang 
					where donhang.creater='$user' or donhang.manager='$user'
					";

	
	$qr1=mysql_query($sqlstring); 
	
  ?>
<table id="box-quick" class="box-quick" border="0" cellpadding="5" cellspacing="0" width="100%">
          <tbody><tr id="title">
           	<td width="3%">STT</td>
            <td width="10%">Ngày bán</td>
            <td width="15%">Tên đơn hàng</td>
            <td width="10%">Khách hàng</td>
            <td width="10%">Giá trị</td>
            <td width="10%">Người quản lý</td>
            <td width="7%">Thao tác</td>
          </tr>
         <?php 
		 $i=1;
		 	while($row=mysql_fetch_array($qr1)) 
			{
				
		 ?>
           <tr class="light"  id="value" style="cursor:pointer;" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)" bgcolor="">
           	<td align="center" style="border-left:1px solid #ccc"><?php echo $i++;?> </td>
             <td align="center" >
           		<?php echo $row['ngayban'];?>
           </td>
            <td  class="tdbg_2" ><div align="left">&nbsp;<span title="">
				<a href="index.php?tn=contract&hd=order_detail&id=<?php echo $row['id'];?>"><?php echo $row['name'];?></a>
                 </span>
                </div>
            </td>
          
             <td align="center">
             	<?php 
				$sql_kh=mysql_query("select id,name_kh,name_com from customers where id='".$row['kh_id']."'");
				$row_kh=mysql_fetch_array($sql_kh);
			 	echo $row_kh['name_com']; echo $row_kh['name_kh'];
				?>
             </td>
            <td align="center">
            	<?php echo $row['giatri'];?>
            </td>
             <td align="center">
			 		<?php
						$nql_id=$row['manager']; 
						$nql_name=catchinfor($nql_id,'account_id','account_name','tb_account_admin');
							echo $nql_name;
					?>
              </td>
          
             <td align="center">          	
				<a onclick="window.location='index.php?tn=contract&hd=order_edit&id=<?php echo $row['id'];?>';"><img width="16" align="absmiddle" src="../skins/images/edit.png"></a>
													
				<a onclick="if(confirm('Bạn muốn xóa đơn hàng này không?')){window.location='index.php?tn=contract&hd=order_del&id=<?php echo $row['id'];?>';}"><img width="16" align="absmiddle" src="../skins/images/del.png"></a>
													
                &nbsp;
                            
             </td>
          </tr>
       
         <?php }?>

        </tbody>
	</table>
  </td>

 <td class="c-r"></td>
        </tr>
        <tr class="light">
          <td class="b-l"></td>
          <td class="b-c"></td>
          <td class="b-r"></td>
        </tr>
      </tbody></table>